/**
 * @file:          FieldWeakeningControl.h
 * @brief:
 * @details:
 * @author:        wjh
 * @date created:  2023.08.19
 * @version:       1.0.0
 * @par copyright (c):
 *
 * @par history (desc):
 *   version:1.0.0, wjh, 2023.08.19,16:00:11
 */

#ifndef _FIELDWEAKENINGCONTROL_H_
#define _FIELDWEAKENINGCONTROL_H_

/* Include Files **************************************************************/
#include "Datatype.h"
#include "common.h"

/* Macro Definition ***********************************************************/
enum FiledWeakeningControl_SpeedSource
{
    FiledWeakeningControl_SpeedSource_SpdRef = 0,
    FiledWeakeningControl_SpeedSource_SpdFdb = 1,
};

/* Data Type Define ***********************************************************/
typedef struct FieldWeakeningControl
{
    /* public data */
    uint16_t param_en;
    uint16_t param_speed_source_mode;
    float param_wm_base; /* unit: rad/s */
    float param_I_max;   /* unit: A */
    uint16_t param_pole_pair;
    float param_phi_e; /* unit: A */
    float param_L;     /* unit: A */

    float iq_limit;
    float *speed_source;
    float *speed_source_ref;
    float *speed_source_fdb;
    float in_torque_ref; /* unit: Nm */
    float in_iq_ref;     /* unit: A */
    float in_wm;         /* unit: rad/s */
    float out_id_ref;    /* unit: A */
    float out_iq_ref;    /* unit :A */

    /* private data */

    /* public method */
    void (*Init)(struct FieldWeakeningControl *self);
    float (*Run)(struct FieldWeakeningControl *self);

    /* private method */

} FieldWeakeningControl;

/* Variable Declare ***********************************************************/

/* Function Declare ***********************************************************/
void FieldWeakeningControl_Init(struct FieldWeakeningControl *self);
float FieldWeakeningControl_Run(struct FieldWeakeningControl *self);

#endif